import logging

class common(object):
    def __init__(self):
        pass

    def get_ip(self,slot,startNum=33,setp = 1,mixVer = "mix7"):
        sw1 = str(slot)[-1]
        sw2 = ('00'+str(slot))[-2]
        add_num = int(sw2)*16 + int(sw1)
        add_num = add_num - 1
        add_num = int(add_num / int(setp))
        ip_address = int(startNum) + add_num
        if mixVer == "mix8":
            ip_address ="192.168.99."+str(ip_address)
        else:
            ip_address ="169.254.1."+str(ip_address)
        # logging.info('MASK '+str(sw2)+str(sw1)+'  IP:'+str(ip_address))
        return ip_address

    def get_port(self,slot,setp = 1):
        slot = int(slot)
        setp = int(setp)
        add_num = int(slot%setp)
        if add_num == 0 :
            add_num = setp
        add_num = add_num - 1
        # print(add_num)
        return str(7801 + add_num)


if __name__ == "__main__":
    common = common()

    # print(get_ip(1,32))
    # print(get_ip(2,32))
    # print(get_ip(3,32))
    # print(get_ip(4,32))
    # print(get_ip(5,32))
    print(common.get_port(1,2))
    print(common.get_port(2,2))
    print(common.get_port(3,2))
    print(common.get_port(4,2))
    print(common.get_port(5,2))
    print(common.get_port(6,2))

    # print(get_port(1,4))
    # print(get_port(2,4))
    # print(get_port(3,4))
    # print(get_port(4,4))
    # print(get_port(5,4))
    # print(get_port(6,4))
    # print(get_port(7,2))
    # print(get_port(2,2))
    # print(get_port(6,4))
    # print(get_port(1,2))